10 edge(int t
, int w
, int l
) : to(t
), weight(w
), lift(l
) {}
11 bool operator < (const edge
&that
) const{
12 return weight
> that
.weight
;
18 while (cin
>> n
>> k
){
21 for (int i
=0; i
<n
; ++i
){
26 for (int i
=0; i
<n
; ++i
){
28 stringstream
ss(line
);
32 g
[x
].push_back(edge(y
, (y
-x
)*t
[i
], i
));
33 g
[y
].push_back(edge(x
, (y
-x
)*t
[i
], i
));
39 for (int i
=0; i
<100; ++i
) for (int j
=0; j
<n
; ++j
) d
[i
][j
] = INT_MAX
;
40 for (int j
=0; j
<n
; ++j
) d
[0][j
] = 0;
42 priority_queue
<edge
> q
;
43 q
.push(edge(0, -60, -1));
45 edge top
= q
.top(); q
.pop();
47 if (top
.to
== k
) break;
48 if (d
[top
.to
][top
.lift
] < top
.weight
) continue;
50 for (int i
=0; i
<g
[top
.to
].size(); ++i
){
51 edge u
= g
[top
.to
][i
];
54 if ((t
= top
.weight
+ u
.weight
+ (top
.lift
!= u
.lift
?60:0)) < d
[u
.to
][u
.lift
]){
56 q
.push(edge(u
.to
, t
, u
.lift
));
60 int a
= *min_element(d
[k
], d
[k
]+n
);
64 cout
<< "IMPOSSIBLE" << endl
;